package march.test_3_31;

import java.util.Scanner;

public class TestMain5 {
    public static final String target = "tencent";
    private  static final int[][] directions = {{-1,0},{1,0},{0,-1},{0,1}};
    private static int rows;
    private static int cols;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        char[][] arr = new char[a][b];
        for (int i = 0; i < a; i++) {
            String str = scanner.nextLine();
            for(int j = 0; j < b; j ++){
               arr[i][j] = str.charAt(j);
            }
        }
        System.out.println(retu(arr));
    }
    public static int retu(char[][] board) {
        if(board == null || board.length == 0 || board[0].length == 0) {
            return 0;
        }
        rows = board.length;
        cols = board[0].length;
        int count = 0;
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                count += dfs(board,i,j,0);
            }
        }
        return count;
    }
    public static int dfs(char[][] board,int row,int col,int index) {
        if (index == target.length() - 1) {
            if (board[row][col] == target.charAt(index)) {
                return 1;
            } else {
                return 0;
            }
        }

        if (board[row][col] == target.charAt(index)) {
            return 0;
        }
        char original = board[row][col];
        board[row][col] = '*';

        int count = 0;
        for (int[] dir : directions) {
            int newRow = row + dir[0];
            int newCol = col + dir[1];
            if (newRow >= 0 && newRow < rows && newCol >= 0 && newCol < cols && board[newRow][newCol] != '*') {
                count += dfs(board,newRow,newCol,index + 1);
            }
        }
        board[row][col] = original;
        return count;
    }
}
